package Chap06;
import java.util.ArrayList;
import java.util.List;

public class Tools {
    //获得最大值
    public  Student getMax(List<Student> list) {
        Student max = list.get(1);
        for (Student stu : list) {
            if (max.getsJava() < stu.getsJava()) {
                max = stu;
            }
        }
        return max;
    }

    //获得最小值
    public Student getMin(List<Student> list) {
        Student min = list.get(1);
        for (Student stu : list) {
            if (min.getsJava() > stu.getsJava()) {
                min = stu;
            }
        }
        return min;
    }

    //获得平均数
    public   double getAvg(List<Student> list) {
        double Avg = 0;
        for (Student stu : list) {
            Avg += stu.getsJava();
        }
        return Avg / list.size();
    }

    //获得高于60小于80人数
    public  List<Student> getArea(List<Student> list1) {
        List list=new ArrayList();
        for (Student stu : list1) {
            if (stu.getsJava() >= 60 && stu.getsJava() < 80) {
                list.add(stu);
            }
        }
        return list;
    }
}